<template>
	<view class="add-class">
		<view class="login-form">
			<uni-forms label-position="top" ref="form" :modelValue="form">
				<uni-forms-item  name="command">
					<uni-easyinput type="password"  class="login-box-input" placeholder="班级口令" v-model.trim="form.joinUrl"/>
				</uni-forms-item>
			</uni-forms>
			<button>保存</button>
		</view>
	</view>
</template>

<script>
export default{
	data(){
		return {
			
			form: {
				joinUrl: ""
			}
		}
	},
	onLoad:function(){
		//获取token
		let token = uni.getStorageSync("token");
		console.log(!token);
		if( !token){
			// uni.showToast({
			// 	title: "请先登录！！"
			// })
			uni.redirectTo ({
				url: "/pages/login/login"
			});
		}
		//获取当前用户的班级信息
		this.getClazz();
	},
	methods:{
		async getClazz(){
			const resp = await this.$myRequest({
				url: "/api/student/classes/currentClazz"
			});
			if( resp.data.code == 200){
				this.clazz = resp.data.obj;
			}
		}
	}
}
</script>

<style lang="scss" scoped>
.add-class{
	display: flex;
	justify-content: center;
	flex-direction: column;
	align-items: center;
	width:100%;
	box-sizing: border-box;
	.login-form{
		
		width:94%;
		margin-top: 50rpx;
		.login-box-input{
			background-color:#F8F8F8 ;
		}
		button{
			margin-top: 40rpx;
			background: #66BB6A;
		}
	}
}
</style>
